﻿using B.Z.BasicData.API.Write.Application.ExcusedManage;
using B.Z.BasicData.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.Z.BasicData.API.Write.Controllers
{
    /// <summary>
    /// 控制器-写（请假管理）
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class ExcusedController : ControllerBase
    {
        private readonly IMediator mediator;

        public ExcusedController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 保存请假单
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddExcused(ExcuseAddCommand command) 
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 修改/删除请假单
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdateOrDelExcused(ExcuseUpdateOrRemoveCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 审批请假单
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> ShenpiExcused(ExcuseShenpiCommand command)
        {
            return await mediator.Send(command);
        }
    }
}
